<template>
  <view class="uni-px-4 bg-gray-50">
    <uni-section title="手機號">
      <template v-slot:right>
        <view @click="goto('/pages/setting/phone')">
          <text class="text-gray-500">+86 {{ phone }}</text>
          <uni-icons type="forward"></uni-icons>
        </view>
      </template>
    </uni-section>
    <!-- <uni-section title="登錄密碼">
      <template v-slot:right>
        <view @click="goto('/pages/setting/password')">
          <text class="text-gray-500">設置</text>
          <uni-icons type="forward"></uni-icons>
        </view>
      </template>
    </uni-section> -->
    <uni-section @click="goto('/pages/user/info')" class="mb-10" title="編輯信息"></uni-section>
    <uni-section @click="goto('/pages/user/account')" class="mb-10" title="賬號安全"></uni-section>
    <uni-section @click="goto('/pages/setting/record')" class="mb-10" title="瀏覽記錄"></uni-section>
    <uni-section class="mb-10" title="隱私設置"></uni-section>
    <uni-section class="mb-10" title="關於一點通"></uni-section>
    <button @click="logout" type="warn" class="uni-mt-10">登出賬戶</button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      phone: '',
    }
  },
  onLoad() {
    const user = getApp().globalData.user
    if (user) {
      this.phone = user.phone || ''
    }
  },
  methods: {
    logout() {
      uni.showModal({
        title: '是否退出登錄',
        content: '退出登錄將清除本機所有數據（包括本地草稿）！',
        success: (res) => {
          if (res.confirm) {
            uni.clearStorage()
            uni.reLaunch({
              url: '/pages/login/login'
            })
          }
        }
      })
    },
    goto(url) {
      uni.navigateTo({
        url
      });
    },
  }
}
</script>

<style lang="scss" scoped></style>
